from api.user import models
from rest_framework import exceptions
from rest_framework.authentication import BaseAuthentication


class Authticatition(BaseAuthentication):

    def authenticate(self, request):
        token = request._request.GET.get("token")
        token_obj = models.UserToken.objects.filter(token=token).first()
        if not token_obj:
            raise exceptions.AuthenticationFailed("用户认证失败")

    def authenticate_header(self, request):
        pass
